import React from 'react';
import { Image, Text, TouchableOpacity, View, TextInput, ImageBackground } from 'react-native';
import Colors from "../constants/Colors";
import { unitWidth, width } from "../constants/AdapterUtil";
import { show } from '../constants/Toast';

//能够正常显示全部内容的自定义text
export class MyTextView extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            height: 0
        }
    }

    render() {
        if (this.state.height == 0) {
            return (<Text style={this.props.style} onLayout={event => {
                if (event.nativeEvent.layout.height > 25) {
                    this.setState({
                        height: event.nativeEvent.layout.height * 1.05
                    })
                }
            }} onPress={this.props.onPress}>{this.props.content}</Text>)
        } else {
            return (
                <Text
                    numberOfLines={this.props.numberOfLines}
                    style={[{ height: this.state.height }, this.props.style]}
                    onPress={this.props.onPress}>{this.props.content}</Text>
            )
        }
    }
}

//中间划线的text
export class DeleteTextView extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            height: 0
        }
    }

    render() {
        return (
            <View style={[{ alignItems: 'center', flexDirection: 'row' }, this.props.style]}>
                <Text style={[{ color: Colors.color99, fontSize: 13, }, this.props.fontSize]}>{this.props.text}</Text>
                <View style={{ position: 'absolute', width: 50 * unitWidth, backgroundColor: Colors.color99, height: 1 }} />
            </View>
        )
    }
}